{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# -*- coding:utf-8 -*-\n",
    "\"\"\"\n",
    "python 版本: Python 3\n",
    "安装库  : pip install requests\n",
    "@File    west_domain_api_demo.py\n",
    "@Author  west.cn\n",
    "@Created on 2023年11月03日\n",
    "\"\"\"\n",
    "import sys\n",
    "import time\n",
    "\n",
    "import requests\n",
    "import hashlib\n",
    "import json\n",
    "import warnings\n",
    "\n",
    "warnings.filterwarnings(\"ignore\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "class DomainApiUtils:\n",
    "    def __init__(self, api_url: str, user_name: str = None, api_password: str = None):\n",
    "        \"\"\" 初始化类，用户认证和域名apidomainkey必选其一\n",
    "\n",
    "        :param api_url  :       接口地址\n",
    "        :param user_name:       在西部数码的账号\n",
    "        :param api_password:    SSL的专用api 密码，在网站https://www.west.cn/manager/API/APIconfig.asp 中设置\n",
    "        \"\"\"\n",
    "        self.api_url = api_url  # api 地址\n",
    "        self.user_name = user_name  # 账号\n",
    "        self.api_password = api_password  # api 密码\n",
    "\n",
    "    def get_public_parm(self, apidomainkey: str = None) -> dict:\n",
    "        \"\"\"    获取公共参数\n",
    "        :param  apidomainkey    域名ApiKey 32位apikey，为域名管理密码的md5值，可在域名控制面板中直接复制\n",
    "        \"\"\"\n",
    "        if apidomainkey:\n",
    "            return {\n",
    "                \"apidomainkey\" : apidomainkey\n",
    "            }\n",
    "        if self.user_name or self.api_password is None:\n",
    "            print(\"API 认证参数错误,apidomainkey 认证或账号认证选择一种。程序退出\")\n",
    "            sys.exit(0)\n",
    "        __apikey = self.get_convert_md5(self.api_password)\n",
    "        __public_parm = {\n",
    "            \"username\": self.user_name,\n",
    "            \"apikey\": __apikey,\n",
    "        }\n",
    "        return __public_parm\n",
    "\n",
    "    def get_convert_md5(self, __string: str, upper: bool = False) -> str:\n",
    "        \"\"\" 计算字符串md5值\n",
    "\n",
    "        :param __string:    输入字符串\n",
    "        :param upper:       是否转大写\n",
    "        :return:            字符串md5\n",
    "        \"\"\"\n",
    "        __my_hash = hashlib.md5()\n",
    "        __my_hash.update(__string.encode('GBK'))\n",
    "        __hash = __my_hash.hexdigest()\n",
    "        if upper:\n",
    "            return str(__hash).upper()\n",
    "        else:\n",
    "            return str(__hash).lower()\n",
    "\n",
    "    def encode_parm(self, __rep_parm: dict, charset: str = 'GBK') -> dict:\n",
    "        \"\"\" 统一转换参数编码\n",
    "\n",
    "        :param __rep_parm:  要转换的字典\n",
    "        :param charset:     字符集\n",
    "        :return:            转换后的新字典\n",
    "        \"\"\"\n",
    "        __encoded_data = {}\n",
    "        for k, v in __rep_parm.items():\n",
    "            if v and isinstance(v, str):\n",
    "                __encoded_data[k] = v.encode(charset, errors='ignore').decode(charset)\n",
    "            else:\n",
    "                __encoded_data[k] = v\n",
    "        return __encoded_data\n",
    "\n",
    "    def do_api(self, __act_url: str, rep_parm: dict = {}, apidomainkey: str = None, isget=True):\n",
    "        '''    调用接口\n",
    "        :param    __act_url     请求 apiurl\n",
    "        :param    rep_parm      请求参数\n",
    "        :param    apidomainkey: api 认证key\n",
    "        :param    isget         非get方法则为post\n",
    "        :return   返回元祖，状态和请求返回结果\n",
    "        '''\n",
    "        #    合并公共参数\n",
    "        if __act_url is not None:\n",
    "            __api_url = self.api_url + __act_url\n",
    "        else:\n",
    "            __api_url = self.api_url\n",
    "        __rep_status, __respon = self.request_act(__api_url, rep_parm, apidomainkey=apidomainkey, isget=isget)\n",
    "        return __rep_status, __respon\n",
    "\n",
    "    def request_act(self, __url: str, __rep_parm: dict, apidomainkey: str = None, isget: bool = True, timeout: int = 10, charset: str = 'GBK'):\n",
    "        '''    post 请求\n",
    "\n",
    "        :param    __url        : 请求url\n",
    "        :param    __rep_parm   : 请求参数\n",
    "        :param    apidomainkey : api 认证key\n",
    "        :param    isget        : 非get方法则为post\n",
    "        :param    timeout      : 超时时间\n",
    "        :param    charset      : 字符集\n",
    "        :return   返回元祖，状态和请求返回结果\n",
    "        '''\n",
    "        try:\n",
    "            session = requests.Session()\n",
    "            session.keep_alive = False                                              #   关闭 多余链接\n",
    "            if isget:\n",
    "                __rep_parm.update(self.get_public_parm(apidomainkey=apidomainkey))  #   合并公共参数\n",
    "                __rep_parm = self.encode_parm(__rep_parm, charset)                  #   转换编码\n",
    "                __respon = session.get(__url, params=__rep_parm, timeout=timeout)\n",
    "            else:\n",
    "                __headers = {\n",
    "                    'Content-Type': f'application/x-www-form-urlencoded;charset={charset}',\n",
    "                }\n",
    "                __rep_parm = self.encode_parm(__rep_parm, charset)\n",
    "                __respon = session.post(__url, data=__rep_parm, params=self.get_public_parm(apidomainkey=apidomainkey), headers=__headers, timeout=timeout)\n",
    "            return True, __respon\n",
    "        except requests.exceptions.Timeout:\n",
    "            return False, {'code': 500, 'msg': f'Request connection timeout......', 'data': None}\n",
    "        except requests.exceptions.ConnectionError as e:\n",
    "            return False, {'code': 500, 'msg': f'Request connection error:{repr(e)}', 'data': None}\n",
    "        except Exception as e:\n",
    "            return False, {'code': 500, 'msg': f'Request error:{repr(e)}', 'data': None}\n",
    "\n",
    "\n",
    "class WestDomainUtils(DomainApiUtils):\n",
    "    def __init__(self, api_url: str, user_name: str = None, api_password: str = None):\n",
    "        \"\"\" 初始化类，用户认证和域名apidomainkey必选其一\n",
    "\n",
    "        :param api_url  :       接口地址\n",
    "        :param user_name:       您在我司的用户名\n",
    "        :param api_password:    认证密码\n",
    "        \"\"\"\n",
    "        #    api 地址\n",
    "        self.api_url = api_url\n",
    "        #    账号\n",
    "        self.user_name = user_name\n",
    "        #    api 密码\n",
    "        self.api_password = api_password\n",
    "        super(DomainApiUtils, self).__init__()\n",
    "\n",
    "    def domain_dnsrec_list(self,__domain: str, hostname: str = None, record_type: str = None, record_value:str = None ,record_line: str = None, limit:int = 20, pageno:int = 1, apidomainkey: str = None):\n",
    "        \"\"\" 获取域名解析\n",
    "\n",
    "        :param __domain  :       查询域名，如www.test.com或test.com\n",
    "        :param hostname:         指定主机头/完整域名\n",
    "        :param record_type:      指定解析类型 限 A,CNAME,MX,TXT,AAAA,SRV\n",
    "        :param record_line:      线路: (默认=\"\" ,电信=\"LTEL\" ,联通=\"LCNC\" ,移动=\"LMOB\" ,教育网=\"LEDU\" , 'LSEO':'搜索引擎', 'LFOR': '境外')\n",
    "        :param record_value:     解析值\n",
    "        :param limit:            每页大小默认20\n",
    "        :param pageno:           第几页\n",
    "        :param apidomainkey:     域名api认证key\n",
    "        \"\"\"\n",
    "        print(\"############### 获取域名解析记录    #####################\")\n",
    "        __rep_parm = {\n",
    "            \"act\": 'dnsrec.list',\n",
    "            \"domain\": __domain,\n",
    "            \"hostname\": hostname,\n",
    "            \"record_type\": record_type,\n",
    "            \"record_line\": record_line,\n",
    "            \"record_value\":record_value,\n",
    "            \"limit\":limit,\n",
    "            \"pageno\":pageno\n",
    "        }\n",
    "        __rep_status, __respon = self.do_api(None, rep_parm=__rep_parm, apidomainkey=apidomainkey, isget=False)\n",
    "        __items =  None\n",
    "        if __rep_status:\n",
    "            __json_data = __respon.json()           # 获取返回json数据\n",
    "            #print(json.dumps(__json_data, indent=4, sort_keys=True).encode('GBK').decode('unicode_escape'))\n",
    "            if __json_data.get('code', 500) == 200:\n",
    "                __body = __json_data.get('body',dict)\n",
    "                if __body:\n",
    "                    __items = __body.get('items',list)\n",
    "                    for __item in __items:\n",
    "                        __hostname = __item.get('hostname',None)\n",
    "                        __record_type = __item.get('record_type',None)\n",
    "                        __record_value = __item.get('record_value',None)\n",
    "                        __record_line = __item.get('record_line',None)\n",
    "                        print(f'hostname:{__hostname}\\nrecord_type:{__record_type}\\nrecord_value:{__record_value}\\nrecord_line:{__record_line}\\n',end='\\n')\n",
    "                    if not __items:\n",
    "                        print('返回数据为空')\n",
    "                else:\n",
    "                    print('返回数据为空')\n",
    "            else:\n",
    "                print('返回状态失败', __json_data.get('msg', None))\n",
    "        else:\n",
    "            print(__respon)\n",
    "        return __items\n",
    "\n",
    "    def domain_dnsrec_add(self,__domain: str, __record_type: str, __hostname: str, __record_value: str, record_line: str = None, record_ttl: int = 900, record_level: int = None, apidomainkey: str = None):\n",
    "        \"\"\" 域名添加解析\n",
    "\n",
    "        :param __domain  :       操作域名。如www.test.com或test.com\n",
    "        :param __record_type:    解析类型 限 A,CNAME,MX,TXT,AAAA,SRV\n",
    "        :param __hostname:       指定子域名主机名或完整子域名， 如www.test.com或www\n",
    "        :param __record_value:   解析值\n",
    "        :param record_line:      线路: (默认=\"\" ,电信=\"LTEL\" ,联通=\"LCNC\" ,移动=\"LMOB\" ,教育网=\"LEDU\" , 'LSEO':'搜索引擎', 'LFOR': '境外')\n",
    "        :param record_ttl:       解析生效时间值 60~86400 单位秒 (默认900)\n",
    "        :param record_level:     优先级别 1-100 默认(10) 仅mx记录有效\n",
    "        :param apidomainkey:     域名api认证key\n",
    "        \"\"\"\n",
    "        print(\"############### 添加域名解析    #####################\")\n",
    "        __rep_parm = {\n",
    "            \"act\": \"dnsrec.add\",\n",
    "            \"domain\": __domain,\n",
    "            \"record_type\": __record_type,\n",
    "            \"hostname\": __hostname,\n",
    "            \"record_value\": __record_value,\n",
    "            \"record_line\": record_line,\n",
    "            \"record_ttl\": record_ttl,\n",
    "            \"record_level\": record_level,\n",
    "        }\n",
    "        __rep_status, __respon = self.do_api(None, rep_parm = __rep_parm, apidomainkey=apidomainkey, isget = False)\n",
    "        if __rep_status:\n",
    "            __json_data = __respon.json()           # 获取返回json数据\n",
    "            #print(json.dumps(__json_data, indent=4, sort_keys=True).encode('GBK').decode('unicode_escape'))\n",
    "            if __json_data.get('code', 500) == 200:\n",
    "                __body = __json_data.get('body')\n",
    "                if __body:\n",
    "                    return True, __body.get('record_id',None)\n",
    "                else:\n",
    "                    return False, \"解析添加成功,body返回未null\"\n",
    "            else:\n",
    "                return False, f\"解析添加失败,{__json_data.get('msg', None)}\"\n",
    "        else:\n",
    "            return False, __respon\n",
    "\n",
    "    def domain_dnsrec_modify(self,__domain: str, __record_type: str, __hostname: str, __record_value: str, record_id: int = None, record_line: str = None, apidomainkey: str = None):\n",
    "        \"\"\" 域名修改解析\n",
    "\n",
    "        :param __domain  :       操作域名。如www.test.com或test.com\n",
    "        :param __record_type:    解析类型 限 A,CNAME,MX,TXT,AAAA,SRV\n",
    "        :param __hostname:       指定子域名主机名或完整子域名， 如www.test.com或www\n",
    "        :param __record_value:   解析值\n",
    "        :param record_id:        指定记录ID(为空或0)\n",
    "        :param record_line:      线路: (默认=\"\" ,电信=\"LTEL\" ,联通=\"LCNC\" ,移动=\"LMOB\" ,教育网=\"LEDU\" , 'LSEO':'搜索引擎', 'LFOR': '境外')\n",
    "        :param apidomainkey:     域名api认证key\n",
    "        \"\"\"\n",
    "        print(\"############### 修改域名解析记录值    #####################\")\n",
    "        __rep_parm = {\n",
    "            \"act\": \"dnsrec.modify\",\n",
    "            \"record_id\": record_id,\n",
    "            \"domain\": __domain,\n",
    "            \"hostname\": __hostname,\n",
    "            \"record_value\": __record_value,\n",
    "            \"record_type\": __record_type,\n",
    "            \"record_line\": record_line,\n",
    "        }\n",
    "        __rep_status, __respon = self.do_api(None, rep_parm=__rep_parm, apidomainkey=apidomainkey, isget=False)\n",
    "        if __rep_status:\n",
    "            __json_data = __respon.json()           # 获取返回json数据\n",
    "            #print(json.dumps(__json_data, indent=4, sort_keys=True).encode('GBK').decode('unicode_escape'))\n",
    "            if __json_data.get('code', 500) == 200:\n",
    "                __body = __json_data.get('body')\n",
    "                if __body:\n",
    "                    return True, __body\n",
    "                else:\n",
    "                    return False, \"解析修改成功,body返回为null\"\n",
    "            else:\n",
    "                return False, f\"解析修改失败,{__json_data.get('msg', None)}\"\n",
    "        else:\n",
    "            return False, __respon\n",
    "\n",
    "    def domain_dnsrec_remove(self,__domain: str, record_id: int = None, record_type: str = None, hostname: str = None, record_line: str = None, apidomainkey: str = None):\n",
    "        \"\"\" 域名删除解析，record_id优先，如没有提供record_id ，hostname和record_type必填写。如果需要指定解析值删除请指定记录ID(record_id优先)\n",
    "\n",
    "        :param __domain  :       操作域名。如www.test.com或test.com\n",
    "        :param record_id:        指定记录ID(为空或0)，优先\n",
    "        :param record_type:      解析类型 限 A,CNAME,MX,TXT,AAAA,SRV\n",
    "        :param hostname:         指定子域名主机名或完整子域名， 如www.test.com或www\n",
    "        :param record_line:      线路: (默认=\"\" ,电信=\"LTEL\" ,联通=\"LCNC\" ,移动=\"LMOB\" ,教育网=\"LEDU\" , 'LSEO':'搜索引擎', 'LFOR': '境外')\n",
    "        :param apidomainkey:     域名api认证key\n",
    "        \"\"\"\n",
    "        print(\"############### 删除域名解析    #####################\")\n",
    "        if record_id and hostname and record_type is None:\n",
    "            return False, F\"record_id 或者 hostname和record_type 不能为空\"\n",
    "        __rep_parm = {\n",
    "            \"act\": \"dnsrec.remove\",\n",
    "            \"record_id\": record_id,\n",
    "            \"domain\": __domain,\n",
    "            \"hostname\": hostname,\n",
    "            \"record_type\": record_type,\n",
    "            \"record_line\": record_line,\n",
    "        }\n",
    "        __rep_status, __respon = self.do_api(None, rep_parm=__rep_parm, apidomainkey=apidomainkey, isget=False)\n",
    "        if __rep_status:\n",
    "            __json_data = __respon.json()           # 获取返回json数据\n",
    "            #print(json.dumps(__json_data, indent=4, sort_keys=True).encode('GBK').decode('unicode_escape'))\n",
    "            if __json_data.get('code', 500) == 200:\n",
    "                __body = __json_data.get('body')\n",
    "                if __body:\n",
    "                    return True, __body\n",
    "                else:\n",
    "                    return False, \"解析删除成功,body返回未null\"\n",
    "            else:\n",
    "                return False, f\"解析删除失败,{__json_data.get('msg', None)}\"\n",
    "        else:\n",
    "            return False, __respon\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "本机公网 IPv6 地址是: 2409:8a38:6c73:dd51:f098:35ab:c996:dce1\n"
     ]
    }
   ],
   "source": [
    "import requests\n",
    "try:\n",
    "    response = requests.get('https://ipv6.icanhazip.com', timeout=10)\n",
    "    if response.status_code == 200:\n",
    "        ipv6_address = response.text.strip()\n",
    "        print(f\"本机公网 IPv6 地址是: {ipv6_address}\")\n",
    "    else:\n",
    "        print(f\"请求失败，状态码: {response.status_code}\")\n",
    "except requests.RequestException as e:\n",
    "    print(f\"请求发生错误: {e}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "api_url = r'https://api.west.cn/API/v2/domain/dns/'  # 接口地址\n",
    "user_name    = 'zhaichengfu'      # 账号\n",
    "api_password = '2hpwgagf'      # api 密码\n",
    "yuMing = 'yeshijixie.com'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "__util = WestDomainUtils(api_url, user_name, api_password)\n",
    "############### 查询域名解析    使用域名apidomainkey认证 #####################\n",
    "__dnsrec_items  = __util.domain_dnsrec_list(yuMing, apidomainkey='bab32ec0c4c880cd692b749a2dfef986')\n",
    "#print(__dnsrec_items)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第[ 1 ]行： record_id: 127636687, hostname: www, record_value: 2409:8a38:6c71:1cd0:31aa:3c53:15b:a91e, record_type: AAAA\n",
      "第[ 2 ]行： record_id: 127636685, hostname: @, record_value: 2409:8a38:6c71:1cd0:31aa:3c53:15b:a91e, record_type: AAAA\n",
      "第[ 3 ]行： record_id: 127636683, hostname: www, record_value: 2409:8a38:6c71:1cd0:31aa:3c53:15b:a91e, record_type: AAAA\n",
      "第[ 4 ]行： record_id: 127636680, hostname: @, record_value: 2409:8a38:6c71:1cd0:31aa:3c53:15b:a91e, record_type: AAAA\n",
      "第[ 5 ]行： record_id: 127636506, hostname: www, record_value: 2409:8a38:6c71:1cd0:31aa:3c53:15b:a91e, record_type: AAAA\n",
      "第[ 6 ]行： record_id: 127636504, hostname: @, record_value: 2409:8a38:6c71:1cd0:31aa:3c53:15b:a91e, record_type: AAAA\n",
      "第[ 7 ]行： record_id: 127636503, hostname: www, record_value: 2409:8a38:6c71:1cd0:31aa:3c53:15b:a91e, record_type: AAAA\n",
      "第[ 8 ]行： record_id: 127636500, hostname: @, record_value: 2409:8a38:6c71:1cd0:31aa:3c53:15b:a91e, record_type: AAAA\n"
     ]
    }
   ],
   "source": [
    "i  = 0\n",
    "for record in __dnsrec_items:\n",
    "    i += 1\n",
    "    print('第[',i,']行：',f\"record_id: {record['record_id']}, hostname: {record['hostname']}, record_value: {record['record_value']}, record_type: {record['record_type']}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "############### 添加域名解析    #####################\n",
      "True 127722343\n"
     ]
    }
   ],
   "source": [
    "############### 添加域名解析    #####################\n",
    "__status,__body = __util.domain_dnsrec_add(yuMing,\"A\",\"bbs\",\"127.0.0.1\" , apidomainkey='bab32ec0c4c880cd692b749a2dfef986')\n",
    "print(__status, __body)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "############### 修改域名解析记录值    #####################\n",
      "True {'success': [127636503], 'fail': []}\n",
      "############### 修改域名解析记录值    #####################\n",
      "True {'success': [127636503], 'fail': []}\n",
      "############### 修改域名解析记录值    #####################\n",
      "True {'success': [127636680], 'fail': []}\n",
      "############### 修改域名解析记录值    #####################\n",
      "True {'success': [127636683], 'fail': []}\n",
      "############### 修改域名解析记录值    #####################\n",
      "True {'success': [127636685], 'fail': []}\n",
      "############### 修改域名解析记录值    #####################\n",
      "True {'success': [127636687], 'fail': []}\n",
      "############### 修改域名解析记录值    #####################\n",
      "True {'success': [127636504], 'fail': []}\n",
      "############### 修改域名解析记录值    #####################\n",
      "True {'success': [127636506], 'fail': []}\n"
     ]
    }
   ],
   "source": [
    "# ecord_line:      线路: (默认=\"\" ,电信=\"LTEL\" ,联通=\"LCNC\" ,移动=\"LMOB\" ,\n",
    "# 教育网=\"LEDU\" , 'LSEO':'搜索引擎', 'LFOR': '境外')\n",
    "\n",
    "############### 修改域名解析    #####################\n",
    "__status,__body = __util.domain_dnsrec_modify(yuMing,\"AAAA\",\"www\",ipv6_address,record_line='', apidomainkey='bab32ec0c4c880cd692b749a2dfef986')\n",
    "print(__status, __body)\n",
    "############### 修改域名解析    #####################\n",
    "__status,__body = __util.domain_dnsrec_modify(yuMing,\"AAAA\",\"www\",ipv6_address,record_line='', apidomainkey='bab32ec0c4c880cd692b749a2dfef986')\n",
    "print(__status, __body)\n",
    "############### 修改域名解析    #####################\n",
    "__status,__body = __util.domain_dnsrec_modify(yuMing,\"AAAA\",\"@\",ipv6_address,record_line='LTEL', apidomainkey='bab32ec0c4c880cd692b749a2dfef986')\n",
    "print(__status, __body)\n",
    "############### 修改域名解析    #####################\n",
    "__status,__body = __util.domain_dnsrec_modify(yuMing,\"AAAA\",\"www\",ipv6_address,record_line='LTEL',apidomainkey='bab32ec0c4c880cd692b749a2dfef986')\n",
    "print(__status, __body)\n",
    "############### 修改域名解析    #####################\n",
    "__status,__body = __util.domain_dnsrec_modify(yuMing,\"AAAA\",\"@\",ipv6_address,record_line='LCNC', apidomainkey='bab32ec0c4c880cd692b749a2dfef986')\n",
    "print(__status, __body)\n",
    "############### 修改域名解析    #####################\n",
    "__status,__body = __util.domain_dnsrec_modify(yuMing,\"AAAA\",\"www\",ipv6_address,record_line='LCNC',apidomainkey='bab32ec0c4c880cd692b749a2dfef986')\n",
    "print(__status, __body)\n",
    "############### 修改域名解析    #####################\n",
    "__status,__body = __util.domain_dnsrec_modify(yuMing,\"AAAA\",\"@\",ipv6_address,record_line='LMOB', apidomainkey='bab32ec0c4c880cd692b749a2dfef986')\n",
    "print(__status, __body)\n",
    "############### 修改域名解析    #####################\n",
    "__status,__body = __util.domain_dnsrec_modify(yuMing,\"AAAA\",\"www\",ipv6_address,record_line='LMOB',apidomainkey='bab32ec0c4c880cd692b749a2dfef986')\n",
    "print(__status, __body)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "############### 修改域名解析    #####################\n",
    "#__status,__body = __util.domain_dnsrec_modify(yuMing,\"A\",\"bbs\",\"127.0.0.2\", apidomainkey='bab32ec0c4c880cd692b749a2dfef986')\n",
    "#print(__status, __body)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "############### 删除解析    没有设置域名apidomainkey认证必须设置用户认证#####################\n",
    "#__status,__body = __util.domain_dnsrec_remove(yuMing,record_type=\"A\",hostname=\"bbs\", apidomainkey='bab32ec0c4c880cd692b749a2dfef986')\n",
    "#print(__status, __body)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
